#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START hasher-priv

rm -rf build/hasher-priv
cp -a hasher-priv build/
cd build/hasher-priv

# Thanks God hasher-priv does NOT use autocrap
make -j${JOBS} \
	CC=${TARGET}-gcc \
	libexecdir=${prefix}/libexec \
	install DESTDIR="`pwd`/inst"

cat >> inst/etc/hasher-priv/system <<EOF
allowed_mountpoints=/proc,/dev/pts
wlimit_time_elapsed=864000
EOF

chmod 751 inst${prefix}/libexec/hasher-priv
chmod 6711 inst${prefix}/libexec/hasher-priv/hasher-priv
find inst/etc/hasher-priv -type f -print0 | xargs -0 -r chmod 644
find inst/etc/hasher-priv -type d -print0 | xargs -0 -r chmod 755
cd inst
find "${prefix#/}" etc/hasher-priv | cpio -pumd "$stage"
cd ../../..
rm -rf build/hasher-priv

# RECIPE END hasher-priv
